function tax(income) {
  let taxAmount = 0;
  if (income <= 5000) {
    taxAmount = 0;
  } else if (income <= 8000) {
    taxAmount = (income - 5000) * 0.05;
  } else {
    taxAmount = (income - 5000) * 0.1 + (3000 * 0.05);
  }
  return taxAmount;
}